/*************************************************************************
    > File Name: book.cpp
    > Author: skylon
    > Site: blog.csdn.net/tcm_zhangpeng  
    > Created Time: 2016年05月15日 星期日 08时54分59秒
 ************************************************************************/

#include"buyer.h"
#include"book.h"

int main()
{
	int i = 0, buyerid, flag;
	
	book *c[2];
	layfolk b1("Liling", 1, "Beijing", 0);
	honoured_guest b2("Wangyao", 2, .6, "Shanghai", 0);
	member b3("Zhaoyanhong", 3, 5, "Guangzhou", 0);
	buyer *b[3] = {
		&b1, &b2, &b3
	};
	
	book c1("7-302-04504-6", "C++ Primer Plus", "Stephen", "RMYD", 99.00);
	book c2("7-402-03388-9", "Data Structure", "Mark", "JXGY", 35.00);

	c[0] = &c1;
	c[1] = &c2;

	cout << "information of people buy book: " << "\n" << "\n";
	for (i = 0; i < 3; i++)
	{
		b[i]->display();
	}
	
	cout << "\n" << "information of books: " << "\n" << "\n";
	for (i = 0; i < 2; i++)
	{
		c[i]->display();
	}

	cout << "\n" << "Please input ID of people buy book: " << "\n";
	cin >> buyerid;
	flag = 0;
	for (i = 0; i < 3; i++)
	{
		if (b[i]->getid() == buyerid)
		{
			flag = 1;
			break;
		}
	}
	if (!flag)
	{
		cout << "ID is doesn't exit." << "\n" << "\n";
	}
	else
	{
		b[i]->setpay(c[0]->getprice());
		b[i]->setpay(c[1]->getprice());
		cout << "\n" << "People needs to pay: " << b[i]->getpay() << "\n";
	}
	return 0;
}


